﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ElementumForever
{
    abstract class Entity : IEntity
    {
        public IScene Scene { get; private set; }
        private List<IComponent> _components;

        public Entity()
        {
            OnCreat();
        }

        protected virtual void OnCreat()
        {
            Color = Color.White;
            Alpha = 1;
            Visiable = true;
            LayerDepth = 0;
            Position=new Vector2();
            _components = new List<IComponent>();
        }

        public void Attach(IScene scene)
        {
            this.Scene = scene;
            Scene.AttachChild(this);
        }

        public void Detach()
        {
            Scene.DetachChild(this);
            this.Scene = null;
        }

        public float LayerDepth
        {
            get;
            set;
        }

        public Vector2 Position
        {
            get;
            set;
        }

        public abstract void OnUpdate(GameTime gameTime);

        public float Alpha
        {
            get;
            set;
        }

        public bool Visiable
        {
            get;
            set;
        }

        public Color Color
        {
            get;
            set;
        }

       abstract public void OnDraw(GameTime gameTime, SpriteBatch spriteBatch);

       abstract public void Dispose();

       public void AddComponent(IComponent component) {
           _components.Add(component);
       }

       public void RemoveComponent(IComponent component)
       {
           _components.Remove(component);
       }

       public List<IComponent> GetComponents() {
           return _components;
       }

    }
}
